home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 8209 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  946 b 

  1. Path: news.uh.edu!usenet
  2. From: gregace@aol.com
  3. Newsgroups: comp.lang.c
  4. Subject: Checking for Ilegal Input
  5. Date: Sat, 02 Mar 1996 08:05:59 -0600
  6. Organization: University of Houston
  7. Message-ID: <313855C7.5E86@aol.com>
  8. NNTP-Posting-Host: sip-14124.public-dialups.uh.edu
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=us-ascii
  11. Content-Transfer-Encoding: 7bit
  12. X-Mailer: Mozilla 2.0GoldB1 (Win95; I)
  13.  
  14. I have a program where you must enter a number between 0 and 15 and check for 
  15. illegal input such as a number not between 0 and 15 or if a character is 
  16. entered.
  17.  
  18. I used the scanf("%d",&number) to read the input.
  19.  
  20. I check the illegal input by
  21.  
  22. while (number<0 or number>15)
  23. { Printf("Enter a again:");
  24.   scanf("%d",&number);
  25. }
  26.  
  27. This check works fine accept when the user enters a character such as the 
  28. letter f. Does anyone know how to check illegal input that is not a number?
  29.  
  30. Any help appreciated!
  31.  
  32. Reply before 3-4-96
  33.  
  34. email:gregace@aol.com
  35.